using System;
using System.Collections.Generic;
using System.Text;
using BusinessObjects.BO_Actions.Products;
using Entity.StoreProcedure;
using BusinessObjects;
using System.Data;
namespace BusinessObjects.BO_GetObjects
{
    public static class BO_Products
    {
        public static DataTable SelectAll(int status)
        {
            try
            {
                BOProducts_Select_All action = new BOProducts_Select_All();
                usp_Products_Select_All entity = new usp_Products_Select_All();
                entity.STATUS = status;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectTop(int rows, int status)
        {
            try
            {
                BOProducts_Select_Top action = new BOProducts_Select_Top();
                usp_Products_Select_Top entity = new usp_Products_Select_Top();
                entity.NUMBERRECORD = rows;
                entity.STATUS = status;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable Search(int product_id)
        {
            try
            {
                BOProducts_Search action = new BOProducts_Search();
                usp_Products_Search entity = new usp_Products_Search();
                entity.PRODUCT_ID = product_id;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectWithPaged(int startIndex, int pageCount, int status)
        {
            try
            {
                BOProducts_Select_WithPaged action = new BOProducts_Select_WithPaged();
                usp_Products_Select_WithPaged entity = new usp_Products_Select_WithPaged();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.STATUS = status;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Insert(int category_id, string product_code, string product_name, string product_description, int region_id, string thumb_image, decimal unit_price, string product_details, int total_view, bool is_display_on_homepage, string module_id, DateTime created_date, string created_by, DateTime modify_date, string modify_by, bool status)
        {
            try
            {
                BOProducts_Insert action = new BOProducts_Insert();
                usp_Products_Insert entity = new usp_Products_Insert();
                entity.CATEGORY_ID = category_id;
                entity.PRODUCT_CODE = product_code;
                entity.PRODUCT_NAME = product_name;
                entity.PRODUCT_DESCRIPTION = product_description;
                entity.REGION_ID = region_id;
                entity.THUMB_IMAGE = thumb_image;
                entity.UNIT_PRICE = unit_price;
                entity.PRODUCT_DETAILS = product_details;
                entity.TOTAL_VIEW = total_view;
                entity.IS_DISPLAY_ON_HOMEPAGE = is_display_on_homepage;
                entity.MODULE_ID = module_id;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;
                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string Update(Int64 product_id, int category_id, string product_code, string product_name, string product_description, int region_id, string thumb_image, decimal unit_price, string product_details, int total_view, bool is_display_on_homepage, string module_id, DateTime created_date, string created_by, DateTime modify_date, string modify_by, bool status)
        {
            try
            {
                BOProducts_Update action = new BOProducts_Update();
                usp_Products_Update entity = new usp_Products_Update();
                entity.PRODUCT_ID = product_id;
                entity.CATEGORY_ID = category_id;
                entity.PRODUCT_CODE = product_code;
                entity.PRODUCT_NAME = product_name;
                entity.PRODUCT_DESCRIPTION = product_description;
                entity.REGION_ID = region_id;
                entity.THUMB_IMAGE = thumb_image;
                entity.UNIT_PRICE = unit_price;
                entity.PRODUCT_DETAILS = product_details;
                entity.TOTAL_VIEW = total_view;
                entity.IS_DISPLAY_ON_HOMEPAGE = is_display_on_homepage;
                entity.MODULE_ID = module_id;
                entity.CREATED_DATE = created_date;
                entity.CREATED_BY = created_by;
                entity.MODIFY_DATE = modify_date;
                entity.MODIFY_BY = modify_by;
                entity.STATUS = status;
                return action.ExecuteAndReturnStringValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Delete(int product_id)
        {
            try
            {
                BOProducts_Delete action = new BOProducts_Delete();
                usp_Products_Delete entity = new usp_Products_Delete();
                entity.PRODUCT_ID = product_id;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Restore(int product_id)
        {
            try
            {
                BOProducts_Restore action = new BOProducts_Restore();
                usp_Products_Restore entity = new usp_Products_Restore();
                entity.PRODUCT_ID = product_id;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool Order(int mid, string list_aid_order)
        {
            try
            {
                BOProducts_Order action = new BOProducts_Order();
                usp_Products_Order entity = new usp_Products_Order();
                entity.MID = mid;
                entity.LIST_AID_ORDER = list_aid_order;
                return action.ExecuteAndReturnBooleanValue(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectByCategory(int startIndex, int pageCount, int category_id)
        {
            try
            {
                BOProducts_Select_By_Category action = new BOProducts_Select_By_Category();
                usp_Products_Select_By_Category entity = new usp_Products_Select_By_Category();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.CATEGORY_ID = category_id;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SearchLike(int startIndex, int pageCount, string keyword)
        {
            try
            {
                BOProducts_Search_Like action = new BOProducts_Search_Like();
                usp_Products_Search_Like entity = new usp_Products_Search_Like();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.KEYWORD = keyword;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SelectAdmin(string keyword, int modue_id, int startIndex, int pageCount, int category_id)
        {
            try
            {
                BOProducts_Select_Admin action = new BOProducts_Select_Admin();
                usp_Products_Select_Admin entity = new usp_Products_Select_Admin();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.CATEGORY_ID = category_id;
                entity.KEYWORD = keyword;
                entity.MODULE_ID = modue_id;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DataTable SearchLikeHome(int startIndex, int pageCount, string keyword)
        {
            try
            {
                BOProducts_Search_Like_Home action = new BOProducts_Search_Like_Home();
                usp_Products_Search_Like_Home entity = new usp_Products_Search_Like_Home();
                entity.STARTINDEX = startIndex;
                entity.MAXRECORDS = pageCount;
                entity.KEYWORD = keyword;
                return action.ExecuteAndReturnDataTable(entity);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}

